home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_02
/
9n02124a
< prev
next >
Wrap
Text File
|
1990-12-15
|
1KB
|
73 lines
/*** IN THE FILE GLOBALS.H ***/
#ifdef ALLOCATE_SPACE /* allocate space for globals */
#define GLOBAL
#define INIT(x) x
#else /* just declare externals */
#define GLOBAL extern
#defint INIT(x)
#endif
/*
NOTE: The INIT(x) macro won't work with aggregates
because it interprets a comma as indicating a new
macro parameter, not as part of the current
parameter. Aggregates are initialized with
#ifdef ALLOCATE_SPACE
*/
GLOBAL
int variable1 INIT(=1),
variable2;
GLOBAL
int variable1 INIT(=1),
variable2;
GLOBAL
struct range
{
int xmin, xmax, ymin, ymax;
} data_range
#ifdef ALLOCATE_SPACE
= { 0, 0, 0, 0, 0 }
#endif
;
/** IN THE MAIN .C FILE ***/
#define ALLOCATE_SPACE
#include "globals.h"
/* So, our inclusion becomes: */
int variable1 = 1,
variable2;
struct range
{
int xmin, xmax,; ymin, ymax;
} data_range = { 0, 0, 0, 0 };
/* IN ALL OTHER .C FILES */
#include "globals.h"
/* So our inclusion becomes: */
extern
int variable1,
variable2;
extern
struct range
{
int xmin, xmax, ymin, ymax;
} data_range;